package com.haierCamera.customapplication.ui.main.widget;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.haierCamera.customapplication.R;

public class ToastDeviceTalk extends Toast {
    private static Toast mToast;


    public ToastDeviceTalk(Context context) {
        super(context);
    }

    public static void showToast(Context context, int type) {

        //获取系统的LayoutInflater
        LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.hzkl_dialog_device_talk, null);

        ImageView iv_logo = (ImageView) view.findViewById(R.id.iv_logo);
        TextView tv_content = (TextView) view.findViewById(R.id.tv_content);

        if (type == 0) {
            iv_logo.setImageResource(R.drawable.hzkl_live_ptz_talk_nor_dialog);
            tv_content.setText("对讲结束");
        } else if (type == 1){
            iv_logo.setImageResource(R.drawable.hzkl_live_ptz_talk_dialog);
            tv_content.setText("对讲开始，请说话");
        }
        view.setBackground(context.getResources().getDrawable(R.drawable.hzkl_dialog_bind_success_bg));
        view.setAlpha(0.3f);
        //实例化toast
        mToast = new Toast(context);
        mToast.setDuration(Toast.LENGTH_SHORT);
        mToast.setGravity(Gravity.CENTER,0,0);
        mToast.setView(view);
        mToast.show();
    }

}
